package com.kinyx.framework.db.sentence.res;

import com.kinyx.framework.db.configs.DBConfigs;
import com.kinyx.framework.db.configs.DBConfigsHelper;

/**
 * 语句
 */
abstract class _Sentence implements com.kinyx.framework.db.sentence.defines.ResSentence {

	/** true: SQL语句; false: HQL语句; */
	protected boolean isSQL = true;

	/** true: 带表别名; false: 不带表别名; */
	protected boolean withTableAlias = false;

	/**
	 * 取语句
	 * @param configs 数据库配置
	 * @param isSQL true: SQL语句; false: HQL语句;
	 * @param withTableAlias true: 带表别名; false: 不带表别名;
	 * @return 语句
	 */
	public abstract String getSentence(DBConfigs configs, boolean isSQL, boolean withTableAlias);

	@Override
	public String getSentence(final DBConfigs configs) { return this.getSentence(configs, this.isSQL, this.withTableAlias); }

	@Override
	public String toString() { return String.format((this.isSQL ? "SQL" : "HQL") + ": [%s]", this.getSentence(DBConfigsHelper.getDBConfigs(null))); }

}
